import 'dart:convert';

import 'package:model_api_test/provider/Provider.dart';

class MyApi {
  MyApi._();
  static MyApi? _instance;
  static MyApi get instance {
    _instance ??= MyApi._();
    return _instance!;
  }

  Future<String?> getStatus() async {
    var res = await Provider.getStatus.request();
    return res.bodyString;
  }

  Future transcribeSegment({
    required int segmentIndex,
    required String audioBase64,
  }) async {
    var body = {'segment_index': segmentIndex, 'audio_base64': audioBase64};
    var s = jsonEncode(body);
    print(s);
    var res = await Provider.transcribe_segment.request(body: body);
    print(res.bodyString);
    return res.body;
  }
}
